Avoid removing inner HTML while replacing text